package com.zjxf.controller;

import com.zjxf.base.bean.po.CmsLandmark;
import com.zjxf.base.common.JSONResponse;
import com.zjxf.base.common.OperationException;
import com.zjxf.controller.common.BaseController;
import com.zjxf.service.CmsLandmarkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 长征路线管理
 * Created by lhn on 2021/4/10.
 */
@Api(tags="LandMarkController",description="长征路线")
@AllArgsConstructor
@RestController
@RequestMapping("/app/landmark/")
public class LandMarkController extends BaseController {

    private final CmsLandmarkService cmsLandmarkService;

    /**
     * 获取长征路线列表
     * @return
     */
    @ApiOperation("长征路线列表")
    @PostMapping("findLandMarks")
    public JSONResponse findLandMarks(){
        List<CmsLandmark> page = cmsLandmarkService.page();
        return success(page);
    }

    /**
     * 获取长征路线详情
     * @param id 路线id
     * @return
     * @throws OperationException
     */
    @ApiOperation("长征路线详情")
    @PostMapping (value = "findLandMarkById/{id}")
    public JSONResponse findLandMarksById(@NotNull @PathVariable Long id){
        CmsLandmark cmsLandmark = cmsLandmarkService.get(id);
        return success(cmsLandmark);
    }
}
